package com.qyhl.webtv.module_news.news.goodlife;


import com.qyhl.webtv.commonlib.entity.news.NewsBean;

import java.util.List;

/**
 * Created by qyhl on 2017/11/24.
 */

public class GoodLifePresenter implements GoodLifeContract.GoodLifePresenter {
    private GoodLifeContract.GoodLifeView mView;
    private GoodLifeModel mModel;

    public GoodLifePresenter(GoodLifeContract.GoodLifeView mView) {
        this.mView = mView;
        this.mModel = new GoodLifeModel(this);
    }

    @Override
    public void getHeaderData() {
        mModel.getHeaderData();
    }

    @Override
    public void getBodyData() {
        mModel.getBodyData();
    }

    @Override
    public void headError() {
        mView.headError();
    }

    @Override
    public void headSuccess(List<NewsBean> beanList) {
        mView.headSuccess(beanList);
    }

    @Override
    public void bodyError(int code, String msg) {
        if (code == 0) {
            mView.bodyNetError(msg);
        } else if (code == 1) {
            mView.bodyEmpty(msg);
        } else {
            mView.bodyError(msg);
        }
    }


    @Override
    public void bodySuccess(List<NewsBean> beanList) {
        mView.bodySuccess(beanList);
    }
}
